// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) definits fieldsfirst ansi space safe 
// Source File Name:   PushSensorView.java

package jones.gui;

import java.awt.*;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JPanel;
import jones.SimpleRobot;

public class PushSensorView extends JPanel
    implements Observer
{

    private static final int OVAL_MARGIN = 10;
    private boolean isPushing = false;

    public PushSensorView()
    {
        isPushing = false;
    }

    public void update(Observable obs, Object obj)
    {
        SimpleRobot robot = (SimpleRobot)obs;
        isPushing = robot.isPushing();
        repaint();
    }

    private synchronized void setPushing(boolean isPushing)
    {
        this.isPushing = isPushing;
    }

    private synchronized boolean isPushing()
    {
        return isPushing;
    }

    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        Dimension size = getSize();
        g.setColor(Color.black);
        g.drawOval(10, size.height / 2, size.width - 20, size.height);
        if (isPushing())
        {
            g.setColor(Color.blue);
            g.fillOval(10, size.height / 2, size.width - 20, size.height);
        }
    }
}
